package edu.terapia.model;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration;

public class CreaTablas {

	public static void main(String[] args) {
		CreaTablas c = new CreaTablas();
		c.exec();
	}
	
	private static SessionFactory sessionFactory;

    static {
       try {
           sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
        }
        catch(Throwable t) {
            throw new ExceptionInInitializerError(t);
        }
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }

    public static void shutdown() {
        getSessionFactory().close();
    }
	
	public void exec() {
	    SessionFactory factory = getSessionFactory();
	    Session session = factory.openSession();
	    Transaction t = session.beginTransaction();
	    shutdown();
	}

}
